from mysql_qa.bm25_search import BM25Search
from mysql_qa.mysql_client import MySQLClient
from mysql_qa.redis_client import RedisClient


def _test_bm25_search():
    mysql_client = MySQLClient()
    redis_client = RedisClient()
    bm25_search = BM25Search(redis_client, mysql_client)
    querys = [i[1] for i in mysql_client.fetch_all_questions()]
    count = 0
    not_hit = []
    for query in querys:
        res = bm25_search.search(query)
        if res:
            count += 1
        else:
            not_hit.append(query)
    print(f'命中率={count / len(querys)}')
    print(f'未命中的query={not_hit}')


def _test_rag_system():
    # vector_store = VectorStore()
    #
    # # 示例：完整查询处理
    # query = "AI学科学费是多少？"
    # rag_system = RAGSystem(vector_store, llm)
    # answer = rag_system.generate_answer(query)
    # print(answer)
    pass


if __name__ == '__main__':
    _test_bm25_search()
    _test_rag_system()
